import request from '@/utils/request'

// 分页
export function pagingPartner(query) {
  return request({
    url: '/user/enterprisePartner/paging',
    method: 'get',
    params: query
  })
}

// 统计
export function statPartnerIncome(query) {
  return request({
    url: '/user/enterprisePartner/statPartnerIncome',
    method: 'get',
    params: query
  })
}

// 企业合伙人 批量启用/禁用
export function updateBatchStatus(partnerIds, partnerStatus) {
  const entity = {
    partnerIds: partnerIds,
    partnerStatus: partnerStatus
  }
  console.log(entity)
  return request({
    url: '/user/enterprisePartner/updateBatchStatus',
    method: 'post',
    params: entity
  })
}

// 删除
export function deleteById(partnerId) {
  return request({
    url: '/user/enterprisePartner/delete',
    method: 'get',
    params: {
      partnerId
    }
  })
}

// 重置密码
export function doResetPwd(partnerId) {
  return request({
    url: '/user/enterprisePartner/doResetPwd',
    method: 'get',
    params: {
      partnerId
    }
  })
}

// 设置企业默认二级合伙人提成比列
export function getTwoPartnerRoyaltyRatio(enterpriseId) {
  return request({
    url: '/user/enterprisePartner/getTwoPartnerRoyaltyRatio',
    method: 'get',
    params: {
      enterpriseId
    }
  })
}

// 设置企业默认二级合伙人提成比列
export function saveEnterpriseConfig(enterpriseId, twoPartnerRoyaltyRatio) {
  return request({
    url: '/user/enterprisePartner/saveEnterpriseConfig',
    method: 'post',
    params: {
      enterpriseId: enterpriseId,
      twoPartnerRoyaltyRatio: twoPartnerRoyaltyRatio
    }
  })
}

// 保存
export function savePartner(enterprisePartnerDTO) {
  return request({
    url: '/user/enterprisePartner/save',
    method: 'post',
    params: enterprisePartnerDTO
  })
}

// 合伙人H5链接二维码
export function getEnterpriseH5QRCode(enterpriseId) {
  return request({
    url: '/user/enterprisePartner/getEnterpriseH5QRCode',
    method: 'get',
    params: {
      enterpriseId
    }
  })
}
// 计划选择合伙人，弹窗使用
export function pagingSelectPartnerByPlan(query) {
  return request({
    url: '/user/enterprisePartner/pagingSelectPartnerByPlan',
    method: 'get',
    params: query
  })
}
// 统计二级合伙人
export function statTwoPartner(query) {
  return request({
    url: '/user/enterprisePartner/statTwoPartner',
    method: 'get',
    params: query
  })
}
// 二级合伙人 批量通用/拒绝
export function updateBatchApplyStatus(params) {
  return request({
    url: '/user/enterprisePartner/updateBatchApplyStatus',
    method: 'post',
    params: params
  })
}
